package com.example.demo.system.controller;

import com.example.demo.system.entity.Log;
import com.example.demo.system.service.LogService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotBlank;
import javax.validation.Valid;
/**
* @author 许久龙
* @since 2022-02-19
*/
@RestController
@RequestMapping("api")
public class LogController {

    @Autowired
    private LogService logService;

    @GetMapping("/log")
    @ApiOperation("Log查询单个")
    public ResultVO getLog(@RequestBody Log log){
     ResultVO resultVO = logService.getLog(Log log);
     return  resultVO;
   }

    @GetMapping("/log")
    @ApiOperation("Log查询全部")
    public ResultVO getAllLog(){
        ResultVO resultVO = logService.getAllLog();
        return  resultVO;
    }

    @PostMapping("/log")
    @ApiOperation("Log新增")
    public ResultVO add(@Valid @RequestBody Log log) {
        ResultVO resultVO = logService.add(Log log);
        return  resultVO;
    }

    @PutMapping("/log")
    @ApiOperation("Log修改")
    public ResultVO update(@Valid @RequestBody Log log) {
        ResultVO resultVO = logService.update(Log log);
        returnresultVO;
    }


    @DeleteMapping(value = "/log/{ids}")
    @ApiOperation("Log删除(单个条目)")
    public ResultVO remove(@NotBlank(message = "{required}") @PathVariable String ids) {
        ResultVO resultVO = logService.remove(String ids);
        return resultVO;
    }
}
